<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>滴答办公系统-部门列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script src="media/js/jquery.min.js"></script>
<style type="text/css">
  td > .layui-table-cell{
      height:48px;
      line-height: 48px;
  }
</style>
</head>
<body>
	<div class="layui-container">
            
    <table class="layui-table" id="layui_table_id" lay-filter="dataTable1"></table>
            
	</div>
	<script src="media/layui/layui.js"></script>
  
  <script type="text/html" id="operate">
     <a class="layui-btn layui-btn-mini" href="departupdate.html?id={{d.id}}">编辑</a>
     <a class="layui-btn layui-btn-danger layui-btn-mini" onclick="deleteDepart({{d.id}});">删除</a>
  </script>
	
	<script type="text/javascript">
     
     layui.use('table', function() {
       var table = layui.table;
     
       //第一个实例
       table.render({
         id: "dataTable1",
         elem: '#layui_table_id',
         height: 510,
         url: '/emp/depart/getDepartsList', //数据接口
         page: true,
         limit: 10,
         contentType: "application/x-www-form-urlencoded",
         method: 'post',
         cols: [
           [ //表头
             {
               field: 'id',
               title: 'ID',
               width: 85,
               align: 'center',
               sort: true
             }, {
               field: 'name',
               title: '部门名称',
               width: 260,
               align: 'center'
             }, {
               field: 'empNum',
               title: '部门人数',
               width: 260,
               align: 'center'
             }, {
               field: 'createtime',
               title: '成立日期',
               width: 260,
               align: 'center'
             }, {
               title: '操作',
               width: 269,
               align: 'center',
               templet: '#operate'
             }
           ]
         ]
       });
     
     });
     
     /*用户-删除*/
     function deleteDepart(id) {
       layer.confirm('确认要删除吗？', function() {
     
         $.ajax({
           method: "POST",
           url: "/emp/depart/delDepart",
           data: {
             id: id
           }, //提交表单的数据
           success: function(res) {
            window.location.reload();
           },
           error: function() {
             layer.close(loading);
             layer.msg('操作失败', {
               icon: 2
             });
           }
         });
       });
     }
	</script>
	
	
</body>
</html>